<template>
	<view>
		<view v-if=" detail.shop_id " class="container">
			<view class="header">
				<view class="shop-logo">
					<image :src=" detail.logo.file_path "></image>
				</view>
				<view class="shop-name">
					<text>{{ detail.shop_name }}</text>
				</view>
				<view v-if=" detail.summary " class="shop-summary dis-flex">
					<text>门店简介：{{ detail.summary }}</text>
				</view>
			</view>
			<view class="content">
				<view class="content-item dis-flex flex-y-center">
					<view class="content-item__icon dis-flex">
						<text class="iconfont icon-shijian"></text>
					</view>
					<view class="content-item__text flex-box dis-flex">
						<text class="f-26">{{ detail.shop_hours }}</text>
					</view>
				</view>
				<view @tap="onOpenLocation" class="content-item dis-flex flex-y-center">
					<view class="content-item__icon dis-flex">
						<text class="iconfont icon-dingwei"></text>
					</view>
					<view class="content-item__text flex-box dis-flex">
						<text class="f-26">{{detail.province_id}}{{detail.city_id}}{{detail.region_id}}{{detail.address}}</text>
					</view>
					<view class="content-item__arrow dis-flex">
						<text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
					</view>
				</view>
				<view @tap="onMakePhoneCall" class="content-item dis-flex flex-y-center">
					<view class="content-item__icon dis-flex">
						<text class="iconfont icon-dianhua"></text>
					</view>
					<view class="content-item__text flex-box dis-flex">
						<text class="f-26">{{ detail.phone }}</text>
					</view>
					<view class="content-item__arrow dis-flex">
						<text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 门店详情
				detail: {},

			}
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(options) {
			let _this = this;
			// 获取门店详情
			_this.getShopDetail(options.shop_id);
		},

		methods: {
			/**
			 * 获取门店详情
			 */
			getShopDetail(shop_id) {
				let _this = this;
				_this._get('shop/detail', {
					shop_id
				}, function(result) {
					_this.setData(result.data);
				});
			},

			/**
			 * 分享当前页面
			 */
			onShareAppMessage() {
				let _this = this;
				// 构建页面参数
				let params = _this.getShareUrlParams({
					'shop_id': _this.detail.shop_id
				});
				return {
					title: _this.detail.article_title,
					path: "/pages/article/detail/index?" + params
				};
			},

			/**
			 * 拨打电话
			 */
			onMakePhoneCall() {
				let _this = this;
				uni.makePhoneCall({
					phoneNumber: _this.detail.phone
				});
			},

			/**
			 * 查看位置
			 */
			onOpenLocation() {
				let _this = this,
					detail = _this.detail;
				uni.openLocation({
					name: detail.shop_name,
					address: detail.region.province + detail.region.city + detail.region.region + detail.address,
					longitude: Number(detail.longitude),
					latitude: Number(detail.latitude),
					scale: 15
				});
			},

		}
	}
</script>

<style>
	page,
	.container {
		background: #fff;
	}

	.container {
		padding: 0 30upx;
	}

	.header {
		padding: 30upx 0;
		border-bottom: 1upx solid #f1f1f1;
	}

	.shop-logo,
	.shop-name {
		text-align: center;
	}

	.shop-logo image {
		width: 130upx;
		height: 130upx;
		border-radius: 50%;
		box-shadow: 0 0 30upx rgba(0, 0, 0, 0.1);
	}

	.shop-name {
		margin-top: 16upx;
		font-size: 32upx;
	}

	.shop-summary {
		padding: 20upx;
		margin-top: 30upx;
		font-size: 26upx;
		line-height: 1.6;
		background: #f9f9f9;
		border-radius: 6upx;
	}

	.content {
		margin-top: 30upx;
	}

	.content-item {
		padding: 12upx 0;
	}

	.content-item__text {
		padding: 0 20upx;
	}
</style>
